package com.example.lots_of_demo.controller;

import com.example.lots_of_demo.security.SecurityUser;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @author : LZJ
 * @description : code for LZJ
 * @date : 2021/2/16
 */
public class BaseController {

    /**
     * 获取当前访问的用户对象
     * @return 当前访问的用户对象
     */
    public SecurityUser getLoginUser(){
        return  (SecurityUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    }

}
